﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ZealousTTS.Domain;
using ZealousTTS.Web.ViewModels;

namespace ZealousTTS.Web.Utility
{
    public static class SessionCache
    {
        public static UserViewModel CurrentUser
        {
            get
            {
                if (HttpContext.Current.Session == null)                
                    return null;
                
                if (HttpContext.Current.Session["CURRENT_USER"] == null) return null;
                return HttpContext.Current.Session["CURRENT_USER"] as UserViewModel;
            }
            set
            {
                if (HttpContext.Current.Session != null)                
                    HttpContext.Current.Session["CURRENT_USER"] = value;                
            }
        }
        public static int RegisteringCompanyID
        {
            get
            {
                if (HttpContext.Current.Session == null)
                    return 0;

                if (HttpContext.Current.Session["REGISTERING_COMPANY_ID"] == null) return 0;
                return (int)HttpContext.Current.Session["REGISTERING_COMPANY_ID"];
            }
            set
            {
                if (HttpContext.Current.Session != null)
                    HttpContext.Current.Session["REGISTERING_COMPANY_ID"] = value;
            }
        }
        /// <summary>
        /// Clears the session.
        /// </summary>
        public static void ClearSession()
        {
            HttpContext.Current.Session.Clear();
        }
    }
}